package restaurant;

import restaurant.iterators.Iterator;

/**
 * The Class cmdMenu.
 * 
 * @author Ebonie
 */

public class cmdMenu implements Command
{

	/** The info. */
	private InformationAggregator info;



	/**
	 * Instantiates a new cmd menu.
	 * 
	 * @param info the info
	 */
	public cmdMenu(InformationAggregator info) {
		this.info = info;
	}



	/**
	 * Execute.
	 * 
	 * @return the menu.
	 * @see restaurant.Command#execute()
	 */
	@Override
	public Object execute()
	{

		Menu menu = info.getMenu();
		Iterator iterator = menu.getStandardIterator();
		MenuItem item;
		Menu entireMenu = new Menu();

		while (iterator.hasNext()) {
			item = (MenuItem) iterator.next();

			if (item.isAvailable())
				entireMenu.add(item);
		}

		return entireMenu;
	}

}
